package com.zhy.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

/**
 * 事件发布类
 * Created by zhy on 2017/4/27.
 */
@Component
public class DemoPublisher {

    //注入ApplicationContext用来发布事件
    @Autowired
    ApplicationContext applicationContext;

    /**
     * 发布
     * @param msg
     */
    public void publish(String msg) {
        applicationContext.publishEvent(new DemoEvent(this, msg));
    }

}
